#!/usr/bin/env python
from socket import *

# server - (host, port)
def testConn(server):
	# create client socket and connect
	s = socket(AF_INET,SOCK_STREAM)
	s.connect(server)
	
	# send message
	s.send('Hello')
	print s.recv(1024)
	
	# close socket
	s.close()

def batchTestConn(host, port, times=1):
	for i in range(times):
		print i, ': Trying to connect ', host, ':', port
		testConn((host, port))

def main():
	serverHost = '127.0.0.1'
	serverPort = 3121
	batchTestConn(serverHost, serverPort, 10)
	
if __name__ == "__main__":
    main()